<template>
  <div class="myNav">
    <span @click="gocity">{{city}} <i></i></span>
    <ul>
      <router-link
        v-for="item in list"
        :key="item.title"
        :to="item.url"
        tag="li"
      >
        {{ item.title }}
      </router-link>
    </ul>
    <i class="iconfont icon-sousuo" @click="gosearch"></i>
  </div>
</template>

<script>
// import { mapState, mapMutations, mapActions } from "vuex";
import { mapState } from "vuex";

export default {
  data() {
    return {
      list: [
        {
          title: "热映",
          url: "/home/movies/hot"
        },
        {
          title: "影院",
          url: "/home/movies/cinema"
        },
        {
          title: "待映",
          url: "/home/movies/wait"
        },
        {
          title: "经典电影",
          url: "/home/movies/classical"
        }
      ],
      colorindex: 0
    };
  },
  methods: {
    fn(i, url) {
      this.colorindex = i;
      this.$router.push(url);
    },
    gocity() {
      this.$router.push("/city");
    },
    gosearch() {
      this.$router.push("/search");
    }
  },
  computed: mapState({ city: state => state.city.city })
};
</script>

<style lang="less" scoped>
@import "../../assets/css/var.less";
.myNav {
  display: flex;
  align-items: center;
  height: 45px;
  border-bottom: @border-color 1px solid;
  background-color: #fff;
  position: relative;

  span {
    font-size: @m-size;
    margin-left: 3px;
    text-align: center;
    width: 65px;
    .ellipsis();
    i {
      position: absolute;
      left: 60px;
      width: 0;
      height: 0;
      border: 4px solid #b0b0b0;
      border-left-color: transparent;
      border-right-color: transparent;
      border-bottom-color: transparent;
      display: inline-block;
      margin-left: 4px;
      margin-top: 5px;
    }
  }

  ul {
    display: flex;
    font-size: @s-size;
    flex: 1;
    margin: 0 10px;
    li {
      flex: 1;
      .center();
    }
    li:last-child {
      flex: 2;
    }
    .router-link-active {
      font-weight: 700;
      font-size: @m-size;

      &::after {
        content: "";
        width: 20px;
        position: absolute;
        bottom: 3px;
        border-bottom: @theme-color 3px solid;
        border-radius: 1.5px;
      }
    }
  }

  > i {
    width: 40px;
    font-size: @xl-size;
    font-weight: 900;
    color: @theme-color;
  }
}
</style>
